﻿<UserControl x:Class="InteractivityQuickstart.Views.ItemSelectionView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             Width="400">
    <Grid>
        
        <StackPanel>

            <TextBlock FontSize="24" Foreground="DarkBlue" Margin="10">ItemSelectionView</TextBlock>

            <TextBlock Margin="10" TextWrapping="Wrap">
                This view has its own view model that implements the <Bold>IInteractionRequestAware</Bold> interface.
                Thanks to this, the view model is automatically populated with the corresponding "notification" 
                and an action to finish the interaction, which in this case closes the window.
            </TextBlock>

            <TextBlock Margin="10" TextWrapping="Wrap" FontWeight="Bold">Please select an item:</TextBlock>
            <ListBox SelectionMode="Single" Margin="10,0" Height="100" ItemsSource="{Binding Notification.Items}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}"> </ListBox>

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Button AutomationProperties.AutomationId="ItemsSelectButton" Grid.Column="0" Margin="10" Command="{Binding SelectItemCommand}">Select Item</Button>
                <Button AutomationProperties.AutomationId="ItemsCancelButton" Grid.Column="1" Margin="10" Command="{Binding CancelCommand}">Cancel</Button>
            </Grid>

            <TextBlock Margin="10,10,10,20" TextWrapping="Wrap">
                The list of items shown above is passed in the parameter of the InteractionRequest and is stored in the Notification property of the view model.
                This is possible because the items list is wrapped inside an object that implements the <Bold>INotification</Bold> interface.
            </TextBlock>
        </StackPanel>
        
    </Grid>
</UserControl>
